/**
 *
 */
package com.zhuoyue.zhtj.service;

import java.util.List;

import com.eit.eitsite.common.utils.IdGen;
import com.eit.eitsite.modules.gen.util.GenUtils;
import com.zhuoyue.zhtj.common.ResponseCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.eit.eitsite.common.persistence.Page;
import com.eit.eitsite.common.service.CrudService;
import com.zhuoyue.zhtj.entity.Interthing;
import com.zhuoyue.zhtj.dao.InterthingDao;

/**
 * 内部物品管理Service
 * @author hss
 * @version 2017-09-18
 */
@Service
@Transactional(readOnly = true)
public class InterthingService extends CrudService<InterthingDao, Interthing> {
	@Autowired
	private InterthingDao interthingDao;

	public Interthing get(String id) {
		return super.get(id);
	}
	
	public List<Interthing> findList(Interthing interthing) {
		return super.findList(interthing);
	}
	
	public Page<Interthing> findPage(Page<Interthing> page, Interthing interthing) {
		return super.findPage(page, interthing);
	}

	public boolean findByNum(Interthing interthing){
		if(interthingDao.findByNum(interthing)>= ResponseCode.ERROR.getCode()){
			return true;
		}
		return false;
	}
	
	@Transactional(readOnly = false)
	public void save(Interthing interthing) {
		if (interthing.getIsNewRecord()){
			interthing.setIsNewRecord(true);
			interthing.setId(IdGen.uuid());

		}
		super.save(interthing);
	}
	
	@Transactional(readOnly = false)
	public void delete(Interthing interthing) {
		super.delete(interthing);
	}
	
}